#include "WidgetVariantFunction.h"
#include <QtCore/QVariant>
#include <iostream>
#include <WidgetsManager.h>
#include <WidgetVariantBool.h>
#include <WidgetVariantColor.h>
#include <WidgetVariantDouble.h>
#include <WidgetVariantEnum.h>
#include <WidgetVariantInt.h>
#include <WidgetVariantIntList.h>
#include <WidgetVariantMatrix.h>
#include <WidgetVariantString.h>
#include <WidgetVariantUrl.h>
#include <WidgetVariantVec2.h>
#include <WidgetVariantVec3.h>
#include <WidgetVariantVec4.h>
#include <WidgetVariantButton.h>
#include <WidgetVariantGroup.h>
#include <WidgetVariantTable.h>
#include <WidgetVariantImage.h>
#include <QMetaProperty>

WidgetVariant* WidgetVariantFunction::createWidgetVariant(const QString& typeName)
{
    WidgetVariant* widgetResult = nullptr;
    if(typeName == "bool")
    {
        WidgetVariantBool* widgetPtr = new WidgetVariantBool();
        widgetResult = widgetPtr;
    }
    else if(typeName == "QColor")
    {
        WidgetVariantColor* widgetPtr = new WidgetVariantColor();
        widgetResult = widgetPtr;
    }
    else if(typeName == "double")
    {
        WidgetVariantDouble* widgetPtr = new WidgetVariantDouble();
        widgetResult = widgetPtr;
    }
    else if(typeName == "enum")
    {
        WidgetVariantEnum* widgetPtr = new WidgetVariantEnum();
        widgetResult = widgetPtr;
    }
    else if(typeName == "int" || typeName == "unsigned int")
    {
        WidgetVariantInt* widgetPtr = new WidgetVariantInt();
        widgetResult = widgetPtr;
    }
    else if(typeName == "QList<int>")
    {
        WidgetVariantIntList* widgetPtr = new WidgetVariantIntList();
        widgetResult = widgetPtr;
    }
    else if(typeName == "Matrix" || typeName == "Matrix4x4")
    {
        WidgetVariantMatrix* widgetPtr = new WidgetVariantMatrix();
        widgetResult = widgetPtr;
    }
    else if(typeName == "string")
    {
        WidgetVariantString* widgetPtr = new WidgetVariantString();
        widgetResult = widgetPtr;
    }
    else if(typeName == "QUrl")
    {
        WidgetVariantUrl* widgetPtr = new WidgetVariantUrl();
        widgetResult = widgetPtr;
    }
    else if(typeName == "Vec2" || typeName == "QPointF")
    {
        WidgetVariantVec2* widgetPtr = new WidgetVariantVec2();
        widgetResult = widgetPtr;
    }
    else if(typeName == "Vec3")
    {
        WidgetVariantVec3* widgetPtr = new WidgetVariantVec3();
        widgetResult = widgetPtr;
    }
    else if(typeName == "Vec4")
    {
        WidgetVariantVec4* widgetPtr = new WidgetVariantVec4();
        widgetResult = widgetPtr;
    }
    else if(typeName == "Button")
    {
        WidgetVariantButton* widgetPtr = new WidgetVariantButton();
        widgetResult = widgetPtr;
    }
    else if(typeName == "Table")
    {
        WidgetVariantTable* widgetPtr = new WidgetVariantTable();
        widgetResult = widgetPtr;
    }
    else if(typeName == "Image")
    {
        WidgetVariantImage* widgetPtr = new WidgetVariantImage();
        widgetResult = widgetPtr;
    }
    else if(typeName == "ItemBasePtr")
    {
    }
    else
    {
    }
    return widgetResult;
}

WidgetVariantGroup* WidgetVariantFunction::createWidgetVariantGroup(const QString& groupName)
{
    WidgetVariantGroup* group = new WidgetVariantGroup();
    group->setGroupName(groupName);
    return group;
}
